<template>
  <table class="table table-striped table-sm">
    <thead>
      <tr>
        <th>订单号</th>
        <th>公司名称</th>
        <th>入住人</th>
        <th>酒店</th>
        <th>入离日期</th>
        <th>房型</th>
        <th>房间数</th>
        <th>价格</th>
        <th>服务费</th>
        <th>预订人</th>
        <th>总金额</th>
        <th>总成本</th>
        <th>利润</th>
        <th>生成时间</th>
        <th>状态</th>
        <th></th>
      </tr>
    </thead>
    <tbody>
      <template v-for="info in dataList">
        <tr>
          <td>
            <router-link :to="`/hotel/order/` + info.id">{{
              info.orderNo
            }}</router-link>
            <span class="text-danger" v-if="info.hotelOrderType === 4">
              退
            </span>
          </td>
          <td>
            {{ info.customerName }}
          </td>
          <td>
            <template v-if="info.passengers.length > 0">
              {{ info.passengers[0].name }}
              <span v-if="info.passengers.length > 1">
                等{{ info.passengers.length }}人</span
              >
            </template>
            <template v-else>
              {{ info.passengerName }}
            </template>
          </td>
          <td>{{ info.hotelName }}</td>
          <td>{{ info.checkInDate }}/{{ info.checkOutDate }}</td>
          <td>{{ info.roomType }}</td>
          <td>{{ info.roomCount }}</td>
          <td>{{ info.price }}</td>
          <td>{{ info.serviceCharge }}</td>
          <td>{{ info.operator }}</td>
          <td>{{ info.totalAmount }}</td>
          <td>{{ info.totalCost }}</td>
          <td>{{ info.profit }}</td>
          <td>{{ info.createTime }}</td>
          <td>
            {{ getStatusDesc(info.status) }}
            <span class="text-primary small" v-if="info.payStatus === 2"
              >已销</span
            >
          </td>
          <td class="">
            <router-link :to="`/hotel/order/` + info.id">详情</router-link>
          </td>
        </tr>
      </template>
      <tr v-if="dataList.length === 0">
        <td colspan="18" class="text-center">未找到符合的数据</td>
      </tr>
    </tbody>
  </table>
</template>

<script>
import { showCustomerName } from "@/common/common.js";
import { showHotelOrderStatus } from "@/api/hotel.js";

export default {
  props: {
    dataList: {
      type: Array,
    },
  },
  methods: {
    showDetail: function (id) {
      this.$router.push("/hotel/order/" + id);
    },
    showCustomerName: function (info) {
      return showCustomerName(info);
    },
    getStatusDesc: function (status) {
      return showHotelOrderStatus(status);
    },
  },
};
</script>